package com.gimi.cloud.bbp.app.consumer.service.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.gimi.cloud.bbp.app.consumer.feign.SysConfigFeignService;
import com.gimi.cloud.bbp.app.consumer.service.SysConfigService;
import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.exception.MsgException;
import com.gimi.cloud.bbp.common.utils.reqhead.Util;

@Service
public class SysConfigServiceImpl implements SysConfigService{
	
	@Autowired private SysConfigFeignService feignService;

	@Override
	public void getConfigValueByCfKey(String requestData, HttpServletRequest request, HttpServletResponse response) {
		JSONObject jsonObject = JSONObject.parseObject(requestData);
		if (!jsonObject.containsKey("cfKey")) {
			throw new MsgException(ResponseCodeEnum.SUCCESSED);
		}
		String cfKey = jsonObject.getString("cfKey");
		Util.sendResponse(feignService.getConfigValueByCfKey(cfKey), response);
	}
	

}
